import ToastComponent from '../components/dialog.vue'

const Toast = {};

Toast.install = function (Vue) {
  const ToastConstructor = Vue.extend(ToastComponent)
  const instance = new ToastConstructor();

  instance.$mount(document.createElement('div'))
  document.body.appendChild(instance.$el)
  Vue.prototype.$toast = (title, msg, callback) => {
    instance.title = title;
    instance.message = msg;
    instance.visible = true;
    instance.callback=function(i){
      instance.visible = false;
      callback(i)
    }
  }
}

export default Toast